home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
-archivi
/
-recent2
/
iconv9.lha
/
IconV9
/
examples
/
roman.icn
< prev
next >
Wrap
Text File
|
1996-05-22
|
588b
|
24 lines
#
# R O M A N N U M E R A L S
#
# This program takes Arabic numerals from standard input and writes
# the corresponding Roman numerals to standard outout.
procedure main()
local n
while n := read() do
write(roman(n) | "cannot convert")
end
procedure roman(n)
local arabic, result
static equiv
initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
integer(n) > 0 | fail
result := ""
every arabic := !n do
result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
if find("*",result) then fail else return result
end